﻿@model KL.Store.Web.Models.CCProcessModel
@{
    Layout = null;
    var pageToPrev = 1;
    var pageToNext = Model.PageCount;
    if (Model.Page > 7)
    {
        pageToPrev = Model.Page - 7;
    }
    if ((Model.Page + 7) < Model.PageCount)
    {
        pageToNext = Model.Page + 7;
    }
    var firstPageClass = "";
    if (Model.Page == 1)
    {
        firstPageClass = " class=\"disabled\"";
    }
    var lastPageClass = "";
    if (Model.Page == Model.PageCount)
    {
        lastPageClass = " class=\"disabled\"";
    }
}
@if (Model.PageCount > 1)
{
    <ul class="pagination right">
        <li@(firstPageClass)><a href="@(ViewBag.PageUrl)?Page=1&Sort=@(Model.Sort)&Filter=@(Model.Filter)">&laquo;</a></li>
        @for (var i = pageToPrev; i <= pageToNext; i++)
        {
            <li@{ if (Model.Page == i)
                  { <text> class="active"</text>} }><a href="@(ViewBag.PageUrl)?Page=@(i)&Sort=@(Model.Sort)&Filter=@(Model.Filter)">@(i)</a></li>
        }
        <li@(lastPageClass)><a href="@(ViewBag.PageUrl)?Page=@(Model.PageCount)&Sort=@(Model.Sort)&Filter=@(Model.Filter)">&raquo;</a></li>
    </ul>
}
<ul class="right sortandfilter">
    <li>
        <label for="StartDate">Başlangıç Tarihi</label>
        @Html.TextBoxFor(m => m.StartDate, new { @id = "datetimepicker1", @class = "form-control" })
    </li>
    <li>
        <label for="EndDate">Bitiş Tarihi</label>
        @Html.TextBoxFor(m => m.EndDate, new { @id = "datetimepicker2", @class = "form-control" })
    </li>
    <li>
        <select name="Sort" class="form-control">
            <option value="1" @(Model.Sort == 1 ? " selected=selected" : "")>Tarih</option>
            <option value="2" @(Model.Sort == 2 ? " selected=selected" : "")>Tip</option>
            <option value="3" @(Model.Sort == 3 ? " selected=selected" : "")>İsim</option>
            <option value="4" @(Model.Sort == 4 ? " selected=selected" : "")>Ödeme</option>
            <option value="5" @(Model.Sort == 5 ? " selected=selected" : "")>Order No</option>
        </select>
    </li>
    <li>
        <select name="Filter" class="form-control">
            <option value="T" @(Model.Filter == "T" || Model.Filter == "" ? " selected=selected" : "")>Tümü</option>
            <option value="K" @(Model.Filter == "K" ? " selected=selected" : "")>Sipariş</option>
            <option value="M" @(Model.Filter == "M" ? " selected=selected" : "")>Mail Order</option>
        </select>
    </li>
    <li>
        <button class="btn btn-primary" id="Filtrele">Filtrele</button>
    </li>
</ul>
<div class="clearfix"></div>
@if (!string.IsNullOrEmpty(ViewBag.PageUrl))
{
    <div class="col-xs-12 hidden-md hidden-lg  first last"><span class="hidden-md hidden-lg right"><a href="javascript:void(0);" class="sectionOC" onclick="expandSection('#ListMailOrderPlaceHolder');">Genişlet/Daralt&nbsp;<i class="fa fa-bars"></i></a></span></div>
}
<table class="table table-bordered">
    <thead>
        <tr>
            <td>Borçlu</td>
            <td class="hideOnMobile">Telefon</td>
            <td class="hideOnMobile">TCKN</td>
            <td>Borç</td>
            <td>Ödeme</td>
            <td class="hideOnMobile">Tarih</td>
            <td class="hideOnMobile">Pos/Banka</td>
            <td>Taksit</td>
            <td class="hideOnMobile">Kart Sahibi</td>
            <td class="hideOnMobile">Kart Numarası</td>
            <td class="hideOnMobile">Order No</td>
            <td>Tipi</td>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.PaymentList)
        {
            <tr>
                <td>@(item.FirstName) @(item.LastName)</td>
                <td class="hideOnMobile">@(item.Mobile)</td>
                <td class="hideOnMobile">@(item.TCKimlik)</td>
                <td>@item.OrgPayment.ToString("###,###,##0.00 TL")</td>
                <td>@item.Payment.ToString("###,###,##0.00 TL")</td>
                <td class="hideOnMobile">@item.CreateDate</td>
                <td class="hideOnMobile">@item.BankName</td>
                <td>@item.Installment.ToString()</td>
                <td class="hideOnMobile">@item.CardOwnerName</td>
                <td class="hideOnMobile">@item.CardNumber</td>
                <td class="hideOnMobile">@item.OrderNo</td>
                <td>@(item.Model == "M" ? "Mail Order" : "Sipariş")</td>
            </tr>
        }
    </tbody>
</table>
@if (Model.PageCount > 1)
{
    <ul class="pagination right">
        <li@(firstPageClass)><a href="@(ViewBag.PageUrl)?Page=1&Sort=@(Model.Sort)&Filter=@(Model.Filter)">&laquo;</a></li>
        @for (var i = pageToPrev; i <= pageToNext; i++)
        {
            <li@{ if (Model.Page == i)
                  { <text> class="active"</text>} }><a href="@(ViewBag.PageUrl)?Page=@(i)&Sort=@(Model.Sort)&Filter=@(Model.Filter)">@(i)</a></li>
        }
        <li@(lastPageClass)><a href="@(ViewBag.PageUrl)?Page=@(Model.PageCount)&Sort=@(Model.Sort)&Filter=@(Model.Filter)">&raquo;</a></li>
    </ul>
    <div class="clearfix"></div>
}
<script>
    $('#Filtrele').click(function ()
    {
        var Sort = $('select[name=Sort]').val();
        var Filter = $('select[name=Filter]').val();
        var StartDate = $('input[name=StartDate]').val();
        var EndDate = $('input[name=EndDate]').val();
        window.location.href = '@(ViewBag.PageUrl)?Page=1&Sort=' + Sort + '&Filter=' + Filter + '&StartDate=' + StartDate + '&EndDate=' + EndDate + '';
    });
</script>
